package hot100;

public class Solution69 {
    public int mySqrt(int x) {
        int last = 0;
        int cur = 0;
        int sqrt = 0;
        for (int i = 1; i <= x; i++) {
            cur = last + 2 * sqrt + 1;
            if (last <= x && cur > x) {
                break;
            }
            if (cur == i * i) {
                sqrt++;
                last = cur;
            }
        }
        return sqrt;
    }

    public static void main(String[] args) {
        Solution69 solution69 = new Solution69();
        solution69.mySqrt(8);
    }
}
